package classes;

import pt.iscte.osgi.contracts.annotations.*;

@NotSubclassByClients
public class Student extends AbstractClass{

	public String firstName;
	
	@NotNull
	@MaxLength(10)
	@StringNotEmpty
	public String lastName;
	
	public int age, birthdayYear;
	
	@Max(1000.0f)
	@Min(1.0f)
	public float studentNumber;
	
	@Range(min=1.0f, max=5.0f)
	public float year;
	
	public double test1 = -1, test2 = -1, test3 = -1;
	
	public Student(@NotNull @MaxLength(10) @StringNotEmpty String firstName, String lastName,  @Max(100) @Min(0) int age){
		this.firstName = firstName;
		this.lastName = lastName;
		this.age = age;
		studentNumber = 1;
	}
	
	public Student(@NotNull @MaxLength(10) @StringNotEmpty String firstName, String lastName,  @Max(100) @Min(0) int age, @Range(min=1900,max=2000) int birthdayYear){
		this.firstName = firstName;
		this.lastName = lastName;
		this.age = age;
		this.birthdayYear = birthdayYear;
		studentNumber = 1;
	}
	
	public Student(@NotNull @MaxLength(10) @StringNotEmpty String firstName, String lastName,  @Max(100) @Min(0) int age, float studentNumber, float year){
		this.firstName = firstName;
		this.lastName = lastName;
		this.age = age;
		this.studentNumber = studentNumber;
		this.year = year;
	}
	
	@FirstInvocation
	public void setup1(){
		//do something...
	}
	
	@SingleInvocation
	public void setup2A(){
		//do something...
	}
	
	@SingleInvocation
	public void setup2B(){
		//do something...
	}
	
	@NoInvocationByClients
	public void setup3(){
		//do something...
	}
	
	public void setStudentNumber(float studentNumber){
		this.studentNumber = studentNumber;
	}
	
	public void setYear(float year){
		this.year = year;
	}
	
	public void setTest1(@Min(0.0) @Max(20.0) double grade){
		this.test1 = grade;
	}
	
	public void setTest2(@Range(min=0.0, max=20.0) double grade){
		this.test2 = grade;
	}
	
	public void setTest3(double grade){
		this.test3 = grade;
	}
	
	public void setFirstName(String firstName){
		this.firstName = firstName;
	}
	
	public void setLastName(@NotNull @MaxLength(10) @StringNotEmpty String lastName){
		this.lastName = lastName;
	}
		
	@NotNull
	@StringNotEmpty
	@MaxLength(10)
	public String getFirstName(){
		return firstName;
	}
	
	@Range(min=0.0, max=20.0)
	public double getFinalGrade(){
		return (test1 + test2 + test3) / (double) 3;
	}
	
	@Min(0.0)
	@Max(20.0)
	public double getTest3(){
		return test3;
	}

}
